package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.order.vo.OrderConfirmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author lfy
 * @Description 订单业务控制器
 * @create 2022-10-19 11:28
 */
@Controller
public class OrderController {

    @Autowired
    OrderFeignClient orderFeignClient;

    @GetMapping("/myOrder.html")
    public String orderList(){

        return "order/myOrder";
    }

    /**
     * 跳转到订单确认页
     * @return
     */
    @GetMapping("/trade.html")
    public String orderConfirmPage(Model model){


        //远程调用 order 服务，要到当前订单确认页的数据
        OrderConfirmVo confirmVo = orderFeignClient.getOrderConfirmData().getData();

        model.addAttribute("detailArrayList",confirmVo.getDetailArrayList());
        model.addAttribute("totalNum",confirmVo.getTotalNum());
        model.addAttribute("totalAmount",confirmVo.getTotalAmount());
        model.addAttribute("userAddressList",confirmVo.getUserAddressList());
        model.addAttribute("tradeNo",confirmVo.getTradeNo());

        return "order/trade";
    }
}
